"""Create Ollama client instance."""

import logging
from functools import cache

from ollama import AsyncClient as AsyncOllama

from .ollama_configuration import OllamaConfiguration
from .types import OllamaClientTypes

log = logging.getLogger(__name__)

@cache
def create_ollama_client(
    configuration: OllamaConfiguration
) -> OllamaClientTypes:
    """Create a new Ollama client instance."""
    log.info("Creating Ollama client base_url=%s", configuration.api_base)
    return AsyncOllama(
        host=configuration.api_base,
        timeout=configuration.request_timeout or 180.0,
    )